package Export;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import org.biojava.bio.BioException;
import org.biojavax.bio.db.ncbi.GenbankRichSequenceDB;
import org.biojavax.bio.seq.RichSequence;

public class FetchNCBI{

	public FetchNCBI(String accession,File file) {
		try {
			GenbankRichSequenceDB grsdb = new GenbankRichSequenceDB();
			RichSequence rs = grsdb.getRichSequence(accession);
			FileOutputStream bos = new FileOutputStream(file);
			RichSequence.IOTools.writeGenbank(bos, rs, rs.getNamespace());
			bos.flush();
			bos.close();
		} catch (BioException | IOException be) {
			be.printStackTrace();
		}
	}
}
